//
//  HomeTopView.m
//  Dome
//
//  Created by 沙斌 on 16/4/15.
//  Copyright © 2016年 Dxy. All rights reserved.
//

#import "HomeTopView.h"

@implementation HomeTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


-(void)addItem{

    _img =[[UIImageView alloc]init];
   // _img.backgroundColor = [UIColor blackColor];
    _img.image = [UIImage imageNamed:@"ty"];
    [self addSubview:_img];
    
    _label = [[UILabel alloc]init];
    _label.text =@"23°C";
    [self addSubview:_label];
    
    _time = [[UILabel alloc]init];
    NSDate *now =[NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MM/dd hh:mm"];
    _time.text = [dateFormatter stringFromDate:now];
    [self addSubview:_time];
    
}


-(void)viewFrame{

     [_time mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.mas_top);
         make.bottom.equalTo(self.mas_bottom);
         make.right.equalTo(self.mas_right).with.offset(-5);
         make.width.equalTo(@100);
     }];
    
    [_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top);
        make.bottom.equalTo(self.mas_bottom);
        make.right.equalTo(_time.mas_left).with.offset(-5);
        make.width.equalTo(@40);
    
    }];
    [_img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top);
        make.bottom.equalTo(self.mas_bottom);
        make.right.equalTo(_label.mas_left).with.offset(-5);
        make.width.equalTo(@60);
        
    }];


}

-(void)addView{
    [self addItem];
    [self viewFrame];
//    self.layer.borderWidth = 1;
//    self.layer.borderColor = [[UIColor grayColor] CGColor];
    
}


@end
